package org.nokatag.code;

import java.util.Iterator;

public class BestFitTextRenderer extends AbstractTextRenderer
{

    public BestFitTextRenderer()
    {
    }

    protected void arrangeCharacters(int width, int height, TextString ts)
    {
        double widthRemaining = ((double)width - ts.getWidth() - (double)leftMargin - (double)rightMargin) / (double)ts.getCharacters().size();
        double x = (double)leftMargin + widthRemaining / 2D;
        height -= topMargin + bottomMargin;
        for(Iterator i$ = ts.getCharacters().iterator(); i$.hasNext();)
        {
            TextCharacter tc = (TextCharacter)i$.next();
            double y = (double)topMargin + ((double)height + tc.getAscent() * 0.69999999999999996D) / 2D;
            tc.setX(x);
            tc.setY(y);
            x += tc.getWidth() + widthRemaining;
        }

    }
}
